package cn.txun.csmall.sentinal.study.service;

import cn.txun.csmall.sentinal.study.fallback.GlobalFallbackHandler;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.stereotype.Service;

@Service
public class HelloService {
    /**
     * 如果对资源配置熔断时，需要计算异常数据
     * 不能使用BlockHandler来进行降级
     * 针对熔断，sentinel提供的降级方法是fallback
     * 能管理降级的异常相关类型，比block要多
     * @param name
     * @return
     */
    @SentinelResource(
            value = "sayHiService",
            fallback = "fallbackDosayHi",
            fallbackClass = GlobalFallbackHandler.class,
            exceptionsToIgnore = RuntimeException.class
    )
    public String doSayHi(String name){
        return "Hello！"+name+"：nice to meet you";
    }
}
